//
//  LoginViewController.m
//  一键车讯
//
//  Created by 江玉元 on 14/11/4.
//  Copyright (c) 2014年 lanou.3g.com. All rights reserved.
//

#import "LoginViewController.h"
#import "WebColor.h"

@interface LoginViewController ()
@property (nonatomic, retain) UITextField *nameTextField;
@property (nonatomic, retain) UITextField *pwdTextField;
@property (nonatomic, retain) UIButton *button;

@end

@implementation LoginViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"登录账号";
    self.view.backgroundColor = [WebColor webColorWithName:@"白烟"];
    
    // 用户名：
    self.nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(60, 120, 200, 30)];
    self.nameTextField.backgroundColor = [UIColor whiteColor];
    self.nameTextField.borderStyle = UITextBorderStyleRoundedRect;
    self.nameTextField.placeholder = @"输入账号/邮箱";
    self.nameTextField.clearButtonMode = UITextFieldViewModeAlways;
    [self.view addSubview:_nameTextField];
    [_nameTextField release];
    
    // 密码：
    self.pwdTextField = [[UITextField alloc] initWithFrame:CGRectMake(60, 160, 200, 30)];
    self.pwdTextField.backgroundColor = [UIColor whiteColor];
    self.pwdTextField.borderStyle = UITextBorderStyleRoundedRect;
    self.pwdTextField.placeholder = @"输入密码";
    self.pwdTextField.clearButtonMode = UITextFieldViewModeAlways;  // 在文本框最后有个x号可以直接删除
    self.pwdTextField.secureTextEntry = YES; // 隐藏密码
    [self.view addSubview:_pwdTextField];
    [_pwdTextField release];
    
    // 登陆按钮：
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    self.button.frame = CGRectMake(80, 220, 160, 30);
    [self.button setTitle:@"登陆" forState:UIControlStateNormal];
    self.button.backgroundColor = [WebColor webColorWithName:@"道奇蓝"];
    [self.button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_button];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self.view addGestureRecognizer:tap];
    [tap release];

}

- (void)tapAction:(UITapGestureRecognizer *)tap
{
    [self.view endEditing:YES];
}

- (void)buttonClicked:(UIButton *)button
{
    NSLog(@"登陆成功");
}

- (void)dealloc
{
    [_nameTextField release];
    [_pwdTextField release];
    [_button release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
